package com.are.odisea;

import java.sql.ResultSet;
import java.sql.SQLException;

public class HtmlCategorias {
public HtmlCategorias() {
		
	}
public String LlenarCombo(int id){
	String str = "";
	Categorias gc=null;   	
	db conexion = null;
	try {
		conexion = new db();
		gc = new Categorias(conexion);
		ResultSet rscp=gc.GetCatPadres(id);
		while (rscp.next()){
			str+="<OPTGROUP label='"+rscp.getString(2)+"'>";
			ResultSet rsch=gc.GetCatHijas(rscp.getString(1));
			while (rsch.next()){
				str+="<option  value="+rsch.getString(1)+">"+rsch.getString(2)+"</option>";
			}
			str+="</OPTGROUP>";
		}
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}finally {
		if (conexion != null){
			try {
				conexion.Close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				//out.print("NO se conecto a la base de datps");
				e.printStackTrace();
			}
		}
		
	}
	return str;
}
}
